<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>流浪动物救助系统</title>
    <link href="static/css/style.css" rel="stylesheet">
    <link href="static/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="${path}/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${path}/admin/layui/css/layui.css" media="all">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <link href="static/css/IE8.css" rel="stylesheet">
    <![endif]-->
</head>

<body>
<jsp:include page="header.jsp"></jsp:include>
<section class="ab_img">
    <img src="static/images/contact.jpg">
</section>

<div class="title1">
    <div class="title1_top">
        <h2>个人信息</h2>
    </div>
</div>
<div class="container">
    <div class="row">
        <div class="huanyanshow_con  col-sm-12 col-xs-12">
            <div class="form_3">
                <ul class="clearfix">
                    <input type="hidden" id="userId" value="${users.uid}">
                    <li><label>用户名</label><input type="text" value="${users.uname}" disabled/></li>
                    <li><label>手机号 </label><input type="text" value="${users.uphone}" disabled/></li>
                    <li><label>密码 </label><input type="password" id="password" value="${users.upassword}"/></li>
                    <li><label>姓名 </label><input type="text" value="${users.urealname}" disabled/></li>
                    <li><label>身份证 </label><input type="text" value="${users.uidnumber}" disabled/></li>
                    <c:if test="${users.utype==1}">
                        <li><label>类型 </label><input type="text" value="普通用户" disabled/></li>
                    </c:if>
                    <c:if test="${users.utype==0}">
                        <li><label>类型 </label><input type="text" value="机构用户" disabled/></li>
                    </c:if>

                </ul>
                <a id="commit" class="sum_b">密码修改</a>
            </div>
        </div>


    </div>
    <c:if test="${ empty users.urealname || (users.urealname eq null)}">
        <div class="title1">
            <div class="title1_top">
                <h2>实名认证</h2>
            </div>
        </div>
        <div class="huanyanshow_con  col-sm-12 col-xs-12">
            <div class="form_3">
                <ul class="clearfix">
                    <li><label>姓名</label><input type="text" id="realName"/></li>
                    <li><label>身份证</label><input type="text" id="cardNo"/></li>
                </ul>
                <a id="realNameCommit" class="sum_b">实名认证</a>
            </div>
        </div>
    </c:if>
    <c:if test="${users.utype==0}">
        <div class="title1">
            <div class="title1_top">
                <h2>添加百科知识</h2>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="huanyanshow_con  col-sm-12 col-xs-12">


                    <div class="form_3">
                        <ul class="clearfix">
                            <li><span>文章标题 <i>*</i></span><input type="text" id="kTitle"/></li>
                            <form id="uploadFrom" enctype="multipart/form-data">
                                <input type="file" name="file" id="fileid">

                            </form>

                        </ul>
                        <div class="text_a">
                            <span>文章内容<i>*</i></span><textarea name="" id="kContent"></textarea>
                        </div>
                        <a id="knowledgeCommit" class="sum_b">立即提交</a>
                    </div>
                </div>

            </div>
        </div>


        <div class="title1">
            <div class="title1_top">
                <h2>流浪动物领养信息发布</h2>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="huanyanshow_con  col-sm-12 col-xs-12">
                    <div class="form_3">
                        <ul class="clearfix">
                            <li><span>宝贝名字 <i>*</i></span><input type="text" id="aName"/></li>
                            <li><span>宝贝年龄 <i>*</i></span><input type="text" id="aAge"/></li>
                            <li><span>宝贝性别 <i>*</i></span><input type="text" id="aSex"/></li>
                            <li><span>宝贝品种 <i>*</i></span><input type="text" id="aSpecies"/></li>
                            <li><span>宝贝健康状况 <i>*</i></span><input type="text" id="aHealthCondition"/></li>

                            <form id="animaluploadFrom" enctype="multipart/form-data">
                                <input type="file" name="file" id="animalfileid">
                            </form>

                        </ul>
                        <div class="text_a">
                            <span>宝贝简介<i>*</i></span><textarea name="" id="aIntroduction"></textarea>
                        </div>
                        <a id="animalCommit" class="sum_b">立即提交</a>
                    </div>
                </div>

            </div>
        </div>
    </c:if>
</div>




<!--联系我们-->
<jsp:include page="footer.jsp"></jsp:include>
<!--回到顶部-->
<a class="top"><span class="glyphicon glyphicon-menu-up jiantou"></span></a>
<script src="${path}/user/static/js/bootstrap.min.js"></script>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<!-- layui的js-->
<script src="${path}/admin/layui/layui.js" charset="utf-8"></script>
<script>
    $(window).scroll(function () {
        $(".top").show();
        if ($(window).scrollTop() <= 300) {
            $(".top").hide();
        }
    });
    $(".top").click(function () {
        $("html").animate({"scrollTop": "0px"}, 100); //IE,FF
        $("body").animate({"scrollTop": "0px"}, 100); //Webkit
    });
</script>
<script type="text/javascript">
    $(function () {
        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage, layer = layui.layer;
            $("#commit").click(function () {
                $.ajax({
                    url: "${path}/user/userUpdatePassword",
                    type: "post",
                    dataType: "json",
                    data: {
                        userId: $("#userId").val(),
                        password: $("#password").val()
                    }, success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                                //修改成功
                                location.href = "${path}/user/userExit";
                            });
                        } else {
                            //修改失败，刷新页面
                            layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                                location.reload();
                            });
                        }

                    }
                })
            })
            $("#realNameCommit").click(function () {
                $.ajax({
                    url: "${path}/user/realNameCertification",
                    type: "post",
                    dataType: "json",
                    data: {
                        userId: $("#userId").val(),
                        cardNo: $("#cardNo").val(),
                        realName: $("#realName").val()
                    }, success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                                //修改成功
                                location.reload();
                            });
                        } else {
                            //修改失败，刷新页面
                            layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                                location.reload();
                            });
                        }

                    }
                })
            })

            $("#knowledgeCommit").click(function () {
                if ($("#kTitle").val() == null || $("#kTitle").val() == "") {

                    layer.tips("标题不能为空", "#kTitle")

                } else if ($("#kContent").val() == null || $("#kContent").val() == "") {

                    layer.tips("内容不能为空", "#kContent")

                } else if ($("#kTitle").val() != null && $("#kTitle").val() != "" && $("#kContent").val() != null && $("#kContent").val() != "") {
                    var formData = new FormData();
                    formData.append("file", $("#fileid")[0].files[0]);
                    formData.append("kTitle", $("#kTitle").val());
                    formData.append("kContent", $("#kContent").val());
                    formData.append("uId", ${user.uid});
                    $.ajax({
                        url: "${path}/knowledge/knowledgeAdd",
                        type: "post",
                        processData: false,
                        contentType: false,
                        data: formData,
                        success: function (data) {
                            if (data.code == 0) {
                                layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                                    //发表成功
                                    location.reload();
                                });
                            } else {
                                //发表失败
                                layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                                    location.reload();
                                });
                            }

                        }
                    })
                }

            })


            $("#animalCommit").click(function () {
                if ($("#aName").val() == null || $("#aName").val() == "") {

                    layer.tips("宝贝的名字不能为空", "#aName")

                } else if ($("#aAge").val() == null || $("#aAge").val() == "") {

                    layer.tips("宝贝的年龄不能为空", "#aAge")

                } else if ($("#aSex").val() == null || $("#aSex").val() == "") {

                    layer.tips("宝贝的性别不能为空", "#aSex")

                } else if ($("#aSpecies").val() == null || $("#aSpecies").val() == "") {

                    layer.tips("宝贝的品种不能为空", "#aSpecies")

                } else if ($("#aHealthCondition").val() == null || $("#aHealthCondition").val() == "") {

                    layer.tips("宝贝的健康状况不能为空", "#aHealthCondition")

                } else if ($("#aIntroduction").val() == null || $("#aIntroduction").val() == "") {

                    layer.tips("宝贝的年龄不能为空", "#aIntroduction")

                } else if ($("#aName").val() != null && $("#aName").val() != "" && $("#aAge").val() != null && $("#aAge").val() != "" && $("#aSex").val() != null && $("#aSex").val() != "" &&
                    $("#aSpecies").val() != null && $("#aSpecies").val() != "" && $("#aHealthCondition").val() != null && $("#aHealthCondition").val() != "" && $("#aIntroduction").val() != null && $("#aIntroduction").val() != "") {
                    var formData = new FormData();
                    formData.append("file", $("#animalfileid")[0].files[0]);
                    formData.append("aName", $("#aName").val());
                    formData.append("aAge", $("#aAge").val());
                    formData.append("aSex", $("#aSex").val());
                    formData.append("aSpecies", $("#aSpecies").val());
                    formData.append("aHealthCondition", $("#aHealthCondition").val());
                    formData.append("aIntroduction", $("#aIntroduction").val());
                    formData.append("uId", ${user.uid});
                    $.ajax({
                        url: "${path}/animal/animalAdd",
                        type: "post",
                        processData: false,//告诉jQuery不要去处理发送的数据
                        contentType: false,//告诉jQuery不要去设置Content-Type请求头
                        data: formData,
                        success: function (data) {
                            if (data.code == 0) {
                                layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                                    //发表成功
                                    location.reload();
                                });
                            } else {
                                //发表失败
                                layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                                    location.reload();
                                });
                            }

                        }
                    })
                }

            })


        });
    });
</script>
</body>

</html>